package com.aaa.sbm.controller;

import com.aaa.sbm.constants.ReturnStatus;
import com.aaa.sbm.entity.Emp;
import com.aaa.sbm.service.EmpService;
import com.aaa.sbm.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("emp")
public class EmpController {
    @Autowired
    private EmpService empService;

    /**
     * 员工列表
     * @return
     */
    @GetMapping("list")
    public Result list(){
        return empService.list();
    }

    /**
     * 添加员工
     * @param emp
     * @return
     */
    @PostMapping("add")
    public Result add(@RequestBody Emp emp){
        return empService.add(emp);
    }

    /**
     * 删除员工
     * @param empNo
     * @return
     */
    @DeleteMapping("delete")
    public Result delete(Integer empNo){
        return empService.delete(empNo);
    }

    /**
     * 更新员工
     * @param emp
     * @return
     */
    @PostMapping("update")
    public Result update(@RequestBody Emp emp){
        return empService.update(emp);
    }

    /**
     * 员工分页列表
     * @param map
     * @return
     */
    @GetMapping("page")
    public Result page(@RequestParam Map map){
        System.out.println("================"+map.get("deptNo"));
        return empService.page(map);
    }

    /**
     * 查询所有员工数量
     * @return
     */
    @GetMapping("listCount")
    public Result listCount(){
        return empService.listCount();
    }

}
